home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
smaltalk
/
st80_pr4.lha
/
st80_pre4
/
MoDE
/
MMSOuterEnv-Shan.st
< prev
next >
Wrap
Text File
|
1993-07-24
|
8KB
|
247 lines
StandardSystemController subclass: #MMSStdSysController
instanceVariableNames: 'rootMode '
classVariableNames: ''
poolDictionaries: ''
category: 'MMSOuterEnv-Shan'!
MMSStdSysController comment:
'I detect the cursor actions. When I should be active, I turn on the event generation, activate the rootModeProcess and then monitor the cursor action every 250 msec. When I go off, I stop the event generation and suspend the rootModeProcess.'!
!MMSStdSysController methodsFor: 'control defaults'!
controlActivity
sensor blueButtonPressed & self viewHasCursor
ifTrue:
[self eventQueue disable.
self blueButtonActivity.
self eventQueue enable]! !
!MMSStdSysController methodsFor: 'private'!
rootMode: rMode
"This is to support the Smalltalk 'collapse' and 'expand' window
management. The implementation of these two message changes the
firstSubView of my view. Therefore I have to avoid accessing the
rootMode (which is stored as the first subView in my view) by doing
'self view firstSubView.' The way I get around it is to have an
instance variable that points to the rootMode. Shan April 26, 1989"
rootMode _ rMode! !
!MMSStdSysController methodsFor: 'tracking/replay'!
eventQueue
"Shan 13 July 1990"
^view firstSubView eventQueue! !
!MMSStdSysController methodsFor: 'basic control sequence'!
controlLoop
"Add exception handling. Shan November 17, 1989"
| sc |
sc _ SignalCollection new.
"Catch all signals. There are problems with Ctrl-C. When the user
selects proceed, the eventQ is still asleep. He needs to go to
another window then come back. Make sure not to land right back
to the event-driven window after proceeding."
sc add: Object errorSignal; add: Object userInterruptSignal.
sc
handle:
[:ex |
self eventQueue disable. "Pretent I have done nothing and let the debugger take over
as usual."
ex reject]
do: [self realControlLoop]!
controlTerminate
"Shan 19 July 1990"
| terminateBlock |
terminateBlock _ view firstSubView terminateBlock.
terminateBlock notNil ifTrue: [terminateBlock value].
super controlTerminate!
realControlLoop
"Resume the production of events when enter; suspend it when leave."
"This also allows more than one MMS sessions runing at the same
time without worrying who gets the next event."
"Change the name to add in the Exception-Handling stuffs. Shan November 18, 1989"
| event eq |
eq _ self eventQueue. "Shan 13 July 1990"
(eq isKindOf: TREventQueue) ifTrue:[eq rootModeOrigin: view displayBox origin]. "Shan 20 July 1990"
eq enable.
"To spy, put the last bracket of 'MessageTally spyOn: []' after the
'eq disable'. As I tried it today, most of the time are spent on
meaningful executions. Less than 5 % overhead for event-driven."
[self isControlActive]
whileTrue:
[self controlActivity. "Processor yield."
"This is the place we merge the polling loop with the event
procesing loop."
event _ eq nextWithCursorMoveCompressed. "Shan 25 May 1990"
rootMode processEvent: event.
"Generate leaveMode event for the rootMode."
event selector = #cursorMove ifTrue: [self checkLeaveRootMode: event].
"event free. Shan 20 July 1990"
].
eq disable.
eq flush! !
!MMSStdSysController methodsFor: 'enter/leaveEvent-process'!
checkLeaveRootMode: event
"This method checks if the cursor has moved out of the root mode. If
yes, it informs the rootMode to process the generated leaveMode
event."
"Shan March 15, 1989"
| leaveEvent temp |
(rootMode containsPoint: event origin)
ifTrue: [^self]
ifFalse: ["(rootMode containsPoint: event extent)"
"Shan July 19, 1989"
rootMode cursorIn
ifTrue:
["construct the leaveMode event and send it."
leaveEvent _ event copy.
temp _ leaveEvent origin.
leaveEvent origin: event previousOrigin.
leaveEvent previousOrigin: temp.
"See the comment in Mode>processEnterLeave:. Shan
July 19, 1989"
leaveEvent selector: #leaveMode.
rootMode processLeave: leaveEvent]]! !
!MMSStdSysController methodsFor: 'scheduling'!
open
"Shan Mrach 15, 1989"
view window: view window viewport: (sensor cursorPoint extent: view minimumSize).
status _ #open.
self moveOpened.
self trackFrame.
"Enforce the view's window and viewport to have same size. Shan
March 25, 1989"
"view matchWindowAndViewport. This is done automatically when the
method 'window: viewport:' is executed. Shan April 26, 1989"
"Now we know the absolute position of the rootMode and can start
computing the laying relation."
view firstSubView computeLayering.
ScheduledControllers scheduleActive: self! !
!MMSStdSysController methodsFor: 'menu messages'!
collapse
rootMode unMap.
super collapse!
expand
"The 'enable' message to the EventQ is in pair with the 'disable'
message in the 'collapse' method. Shane April 26, 1989"
super expand.
rootMode map!
frame
view erase.
self moveOpened.
self trackFrame.
rootMode computeLayering.
view displayEmphasized!
move
view erase.
view isCollapsed
ifTrue: [self moveIcon]
ifFalse: [self moveOpened].
rootMode computeLayering.
view displayEmphasized!
newLabel
self eventQueue disable.
super newLabel.
self eventQueue enable! !
StandardSystemView subclass: #MMSStdSysView
instanceVariableNames: 'rootModeProcess '
classVariableNames: ''
poolDictionaries: ''
category: 'MMSOuterEnv-Shan'!
!MMSStdSysView methodsFor: 'controller access '!
defaultControllerClass
^MMSStdSysController! !
!MMSStdSysView methodsFor: 'transforming'!
window: w viewport: v
"This is for the purpose of resizing. Shan April 26, 1989"
super window: w viewport: v.
self matchWindowAndViewport! !
!MMSStdSysView methodsFor: 'window/viewport matching'!
matchWindowAndViewport
"This will make the absolute specification of mode size possible. Shan
March 25, 1989"
| rMode ext |
ext _ self viewport extent.
"Make the window and viewport the same size. Don't send the
message to self since the 'window: viewport:' method defined in this
class makes use of this method. Infinite loop will happen. Shan April
26, 1989"
super window: (0 @ 0 extent: ext)
viewport: self viewport.
"Make the extents of the window and viewport of root mode
equivalent to ext."
rMode _ self firstSubView.
rMode window: (0 @ 0 extent: ext)
viewport: (0 @ 0 extent: ext)! !
!MMSStdSysView methodsFor: 'initialize-release'!
initialize
"Make the borderWidth 2 so that the display of border is handled here
instead of in RootMode which will introduce a black flash. (The
drawing algorithm fills the whole rectangle with the borderColor then
fills the insideColor.) Shan August 14, 1989"
super initialize.
self borderWidth: 2! !
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
MMSStdSysView class
instanceVariableNames: ''!
!MMSStdSysView class methodsFor: 'MMS start up'!
startUp: aRootMode
"Set up the environment for the aRootMode."
"Set up the InputState1 to generate events"
| mmsTopView |
"InputState1 replaceSystemInputState. Shan 11 June 1990"
mmsTopView _ MMSStdSysView new.
mmsTopView addSubView: aRootMode.
aRootMode label notNil
ifTrue: [mmsTopView label: aRootMode label]
ifFalse: [mmsTopView label: 'MMS application'].
aRootMode minimumSize notNil
ifTrue: [mmsTopView minimumSize: aRootMode minimumSize]
ifFalse: [mmsTopView minimumSize: 400 @ 300].
"Tracking and replay. There may be a cleaner way for this. Shan 18 July 1990"
(EventQ isKindOf: TREventQueue) ifTrue: [mmsTopView controller: MMSStdSysController1 new].
mmsTopView controller rootMode: aRootMode.
"After this the next statement won't be executed. It is like the C
exec() system call."
mmsTopView controller open! !